Skip to content

Fix/python plugin tests#484

Open
Preciousuche wants to merge 3 commits into
canopy-network:mainfrom
Preciousuche:fix/python-plugin-tests
Open

Fix/python plugin tests#484
Preciousuche wants to merge 3 commits into
canopy-network:mainfrom
Preciousuche:fix/python-plugin-tests

Conversation

@Preciousuche

Copy link
Copy Markdown

Summary

This PR fixes the packaging configuration and unit test suite for the Python plugin to resolve import errors and compatibility issues under modern Python versions (e.g. Python 3.14+). It also incorporates the latest changes from upstream/main to resolve conflicts.

Changes Made

  1. Packaging Fixes (pyproject.toml):

    • Fixed the setuptools package finder to look for and include the contract package instead of the non-existent plugin package.
    • Listed main module explicitly in py-modules.
    • Corrected the canopy-plugin script entrypoint mapping to main:main.
    • Relaxed the protobuf dependency constraint to protobuf>=4.21.0 (removed the <5.0.0 upper bound) to allow installing versions compatible with Python 3.14's C-API metaclass changes.
  2. Unit Test Improvements:

    • tests/test_config.py: Rewrote configuration tests to align with the actual Config dataclass and helper functions in the codebase.
    • tests/test_contract.py: Overwrote the placeholder tests with a self-contained, stateless/mock-based unit test suite for the core Contract and MessageSend transaction. Removed dependencies on unimplemented tutorial-specific messages (MessageFaucet, MessageReward).
    • Fixed database read key matching logic in mocks (keys generated via join_len_prefix have length prefixes, so actual type markers start at the second byte).
  3. Upstream Synchronization:

    • Merged the latest main branch from canopy-network/canopy (resolving conflicts in the test files).

Verification

Created a clean virtual environment and ran unit tests:

python -m venv venv
.\venv\Scripts\python -m pip install -e .[test]
.\venv\Scripts\python -m pip install --upgrade protobuf
.\venv\Scripts\pytest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants